<template>
	<view>
		<view class="null box-c d-jc-c d-ai-c" v-if="isShow">
			<image class="mt-5" src="../../static/images/activity/shenqing@2x.png" mode=""></image>
			<text class="mt-3">您暂时还没成员记录~</text>
		</view>
		<view class="" v-if="!isShow">
			<view class="team-t">
					<view class="teamSearch">
						<view class="seachInp">
							<image class="InpImg" src="../../static/images/activity/ss@2x.png" mode=""></image>
							<input class="Inp" confirm-type="search" @confirm="confirm" v-model="InpValue" type="text" value="" placeholder="请输入姓名和手机号" />
						</view>
						
					</view>
				</view>
			<view class="teamlist">
					<scroll-view lower-threshold="500" @scrolltolower='nextPage()' scroll-y="true"
						:style="{height:teamHeight+'px'}">
						<view class="teamScroll">
							<view class="teamScroll_content">
								<view class="teamlist_item box d-jc-sb d-ai-c" v-for="(item,index) in teamMember" :key="index">
									<view class="box d-jc-sb d-ai-c">
										<image class="member_img" :src="item.image" mode=""></image>
										<view class="user_Info">
											<view class="">
												{{item.nickName}}
											</view>
											<view class="">
												手机号：{{item.phone}}
											</view>
											<view class="">
												进团时间：{{item.entryTime}}
											</view>
										</view>
									</view>	
									<view class="removeTesm" @tap="remove(item.userId,item.unityId)">
										移出团队
									</view>
								</view>
							</view>
							
						</view>
					</scroll-view>
			</view>		
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				teamHeight: '',
				teamMember:'',
				InpValue:'',
				id:'',
				isShow:false,
				type:''
			}
		},
		onReady() {
			let that = this;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					that.teamHeight = res.windowHeight - uni.upx2px(150) //windoHeight为窗口高度，主要使用的是这个
				}
			})

		},
		onBackPress() {
			uni.$emit("carData", 1)
		},
		onLoad(option) {
			this.id = option.teamid
			this.memberlist()
		},
		methods: {
			confirm(){
				var val = this.InpValue
				if (val >= 0) {
					console.log('数字')
					this.type = 1
				}else{
					console.log('hanzi')
					this.type = 2
				}
				this.search()
			},
			//移除团队
			remove(userId,unityId){
				uni.showModal({
				    title: '提示',
				    content: '确定移出该成员？',
				    success:(res)=> {
				        if (res.confirm) {
				            console.log('用户点击确定');
							this.memberoperation(userId,unityId)
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			//成员列表
			memberlist(){
				this.$api.memberlist({
					unityId:this.id
				}).then((res) => {
					if (res.data.code == 200) {
						console.log(res.data.dataMap)
						this.teamMember = res.data.dataMap
						if(this.teamMember.length<1){
							this.isShow=true
						}else{
							this.isShow=false
						}
					}
				})
			},
			search(){
				if(this.type==1){
					var object = {
						unityId:this.id,
						phone:this.InpValue
					}
				}else if(this.type==2){
					var object = {
						unityId:this.id,
						nickName:this.InpValue,
					}
				}
				this.$api.memberlist(object).then((res) => {
					if (res.data.code == 200) {
						console.log(res.data.dataMap)
						this.teamMember = res.data.dataMap 
					}
				})
			},
			memberoperation(userId,unityId){
				this.$api.memberoperation({
					unityId:unityId,
					userId:userId
				}).then((res) => {
					if (res.data.code == 200) {
						console.log(res.data)
						uni.showToast({
							title: "移除成功",
							duration: 1500,
							icon: "none"
						});
						this.memberlist()
					}
				})
			}

		}
	}
</script>

<style scoped>
	.null>image {
		width: 340rpx;
		height: 340rpx;	
	}	
	.null>text{
		color: #8b8b8b;
	}
	.team-t {
		width: 750rpx;
		height: 140rpx;
		background-color: #FFFFFF;
	}

	.teamSearch {
		width: 690rpx;
		height: 140rpx;
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.seachInp {
		width: 690rpx;
		height: 68rpx;
		background: #FFFFFF;
		border: 3rpx solid #FF7E51;
		border-radius: 34rpx;
		display: flex;
		align-items: center;
	}


	.InpImg {
		width: 36rpx;
		height: 36rpx;
		margin-left: 30rpx
	}

	.Inp {
		width: 450rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		line-height: 45rpx;
		margin-left: 10rpx
	}

	.teamlist {
		width: 750rpx;
		background: #F8F8F8;
	}
	.teamScroll{
		overflow: hidden;
	}
	.teamScroll_content{
		margin-top: 10rpx;
	}
	.teamlist_item {
		width: 690rpx;
		height: 152rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 1rpx 0rpx 0rpx #EEEEEE;
		margin: 0 auto;
		padding: 0 30rpx 0 30rpx;
	}
	.member_img{
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
	}
	.user_Info{
		margin-left: 20rpx;
	}
	.user_Info>view:nth-child(1){
		font-size: 30rpx;
		font-weight: 500;
		color: #333333;
	}
	.user_Info>view:nth-child(2){
		font-size: 24rpx;
		font-weight: 500;
		color: #999999;
	}
	.user_Info>view:nth-child(3){
		font-size: 24rpx;
		font-weight: 500;
		color: #999999;
	}
	.removeTesm{
		width: 180rpx;
		height: 80rpx;
		background: #FFFFFF;
		border: 2rpx solid #FF7E51;
		border-radius: 40rpx;
		font-size: 26rpx;
		font-weight: 500;
		color: #FF7E51;
		text-align: center;
		line-height: 80rpx;
	}
</style>
